package dyl.test;

import java.text.SimpleDateFormat;
import java.util.Date;

import dyl.sys.util.DateUtil;

public class Dyl {
	public static void main(String[] args) throws Exception {
		/* Calendar date = Calendar.getInstance();
	     String year = String.valueOf(date.get(Calendar.YEAR));
	     System.out.println(year);
	     System.out.println(String.valueOf(date.get(Calendar.MONTH))); 
	     System.out.println(String.valueOf(date.get(Calendar.DATE))); 
	    // System.out.println(new Date("2017-12-11"));
	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	 	Date date1 = sdf.parse("2012-12-06");
	 	System.out.println(date1);*/
	 	
	 	/*
	 	 * 
	 	Calendar calendar = Calendar.getInstance();
	 	calendar.add(Calendar.MONTH, 1);
	 	calendar.add(Calendar.DAY_OF_MONTH, -1);
	 	Date lastDayOfMonth = calendar.getTime();
	 	System.out.println(lastDayOfMonth);*/
		/*PublicDataNsyncService g = new PublicDataNsyncService();
		Object i = MethodUtils.invokeMethod(g,"xxxx",new Object[]{"dyl",11,22});
		System.out.println(i);*/
		/*Object[] a  = new Object[]{"11","22"};
		System.out.println(ArrayUtils.toString(a));*/
		
		
		/* SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		 SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		 Date gjsj = sdf.parse("2017-11-17");
		 System.out.println(DateUtil.diffDays(new Date(), gjsj, 1));
		 System.out.println(gjsj.getTime());
		 Date startTime = sdf2.parse("2017-11-17 22:30");
		 Date endtTime = sdf2.parse("2017-11-17 24:00");
		 System.out.println(startTime.getTime());
		 System.out.println(endtTime.getTime());
		 System.out.println(gjsj.getTime()>=startTime.getTime()&&gjsj.getTime()<endtTime.getTime());*/
		 String sql  ="select * from sys_config t where 1=1  and instr(?,t.xznj)>0 and instr(?,t.yxdm)>0and instr(?,t.mzm)>0 and instr(?,t.zzmmm)>0 and instr(?,t.xb)>0 and exists(select 1 from w_xy_yjxx y where y.xh=t.xh and instr(?,y.yjdj)>0) and exists(select 1 from w_sx_yjxx y where y.xh=t.xh and instr(?,y.yjdj)>0 and y.yjlb = 2) and exists(select 1 from w_wg_yjxx y where y.xh=t.xh and instr(?,y.yjdj)>0) and exists(select 1 from w_sl_yjxx y where y.xh=t.xh  and round(sysdate-y.slsj,1)>=? and round(sysdate-y.slsj,1)<=? and round(sysdate-y.slsj,1)>=?)";
		 String para = "[2015,2016, 01,02, 02,06, 0, 女,2016-2017,1, 1,2, 2,3, 2,3, 30, 60, 60]";
		 changeSql(sql, para);
	}
	public static void changeSql(String sql,String para){
		para = para.replace("[","").replace("]","");
		String arr[] = para.split(", ");
		for (int i = 0; i < arr.length; i++) {
			sql = sql.replaceFirst("\\?", "'"+arr[i].trim()+"'");
		}
		System.out.println(sql);
	}
}
